var endPalteType='0';
$( document ).on( "pageshow", "#endPalte", function( event ) {
	endPalteType='0';
	//发表
	$("#dataSubmit_endPalte").on("click",function (){
		startEndPlate("click");
	});
	
	//text输入长度处理
	$( document ).on( "keyup", "#mytext_endPalte", function( event ) {
		textKeyUp();
	});
	//匿名、实名切换
	//tap 当用户敲击某元素时触发
	$( document ).on( "tap", "[name='radioBut']", function( event ) {
		var thisClassName = this.className;
		var another;
		var childrenNode = $(".circle").children();
		if('circle_empty' == thisClassName){
			another = $(".circle");
			another.children().remove();
			another.attr('class','circle_empty');
			$(this).attr('class','circle');
			$(childrenNode).prependTo(".circle");
			endPalteType=$(this).attr("endPalteType");
		}
	});
	//表情选择
	$( document ).on( "tap", "#bq", function( event ) {
		$("#bq").manhuaHtmlArea({
			Event : "click",
			Left : -22,
			Top : 23,			
			id : "mytext_endPalte",
			callbackFun:function (){
				textKeyUp();
			}
		});
	});
	
});
//text输入长度处理
function textKeyUp(){
	var len = $("#mytext_endPalte").val().length; 
	var show = "" + len + "/140"; 
	$("#name_endPalte").html(show); 
}
function startEndPlate(eventName){
	var dataAdv=$("#mytext_endPalte").val();
	access_token=getQueryString("access_token");
	if(dataAdv==undefined || dataAdv==null || dataAdv==""){
		alert_wx("fail","亲，吐槽内容不能为空哦！");
		return false;
	}else if(dataAdv.length<5){
		alert_wx("fail","亲，吐槽内容要大于等于5个字才行哦！");
		return false;
	}
	$("#dataSubmit_endPalte").off(eventName);
	$.ajax({
	  	url: rootPath+"/user/endPlate.do",
	  	type: "POST",
	  	dataType: "text",
		data: "access_token="+access_token+"&data="+dataAdv+"&type="+endPalteType,
	  	success: function( response ) {
	  		var data=$.parseJSON(response);
			if(data.state=="200"){
				alert_wx("success","亲，吐槽成功了！");
				$("#mytext_endPalte").val("");
				$("#name_endPalte").html("0/140"); 
			}else{
				alert_wx("fail",data.msg);
			}
	  	}
	});
}